<?php
require(dirname(dirname(__FILE__)).'/razorpay/razorpay-php/Razorpay.php');
if(!session_id()) { @session_start(); }

  $root = dirname(dirname(dirname(dirname(dirname(dirname(__FILE__)))))); 

if (file_exists($root.'/wp-load.php')) {
      
  require_once($root.'/wp-load.php'); 

}   
error_reporting(0);
$plugin_url = plugins_url('',  dirname(__FILE__));
$base =   dirname(dirname(dirname(__FILE__)));

use Razorpay\Api\Api;

$api = new Api(get_option("moveto_razorpay_key_id"), get_option("moveto_razorpay_key_secret"));

$orderData = [
    'receipt'         => 3456,
    'amount'          => $_SESSION['final_amt'] * 100, // 2000 rupees in paise
    'currency'        => get_option('moveto_currency'),
    'payment_capture' => 1 // auto capture
];

$razorpayOrder = $api->order->create($orderData);
$razorpayOrderId = $razorpayOrder['id'];
$_SESSION['razorpayOrderId'] = $razorpayOrderId;
$session_data = $_SESSION;
echo json_encode($session_data);
?>